﻿using MiniExcelLibs;
using System;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class ExcelHelper
    {
        public static void ToExcel(DataTable dt)
        {
            try
            {
                string path = AppDomain.CurrentDomain.BaseDirectory + "\\Output";
                if (!Directory.Exists(path))
                {
                    Directory.CreateDirectory(path);
                }

                path = Path.Combine(path, DateTime.Now.ToString("yyyy-MM-dd_") + $"{Guid.NewGuid()}.xlsx");
                MiniExcel.SaveAs(path, dt);
            }
            catch (Exception ex)
            {
                throw new Exception(ex.Message);
            }

        }
    }
}
